package com.taomu.app.zongchouhuli.http.utls;

import com.taomu.app.zongchouhuli.framework.UsualViewOperator;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public abstract class HttpObserver<T> implements Observer<T> {

    private UsualViewOperator operator;

    private CompositeDisposable mCompositeDisposable;

    private boolean showLoading = true;

    public HttpObserver(UsualViewOperator operator, CompositeDisposable mDisposable) {
        this.operator = operator;
        mCompositeDisposable = mDisposable;
    }

    @Override
    public void onSubscribe(Disposable d) {
        mCompositeDisposable.add(d);
    }

    @Override
    public void onError(Throwable e) {
        String msg = e.getMessage();

    }

    public void showLoading(){
        if(operator != null){
            operator.showLoadingDialog();
        }
    }

    public void dimissLoading(){
        if(operator != null){
            operator.dismissLoadingDialog();
        }
    }

    public void showTost(String msg){
        if(operator != null){
            operator.showToast(msg);
        }
    }
}
